PROGRAMS := if_else if_else2
GCC := gcc
OBJDUMP := objdump
OBJTOOL := /root/linux-rv-livepatch/tools/objtool/objtool
SRCS := $(addsuffix .c, $(PROGRAMS))
OBJS := $(addsuffix .o, $(PROGRAMS))
_ASMS := $(addsuffix _disasm.txt, $(PROGRAMS))

ifeq ($(TARGET),)
TARGET := $(OBJS)
endif

all: $(TARGET)

$(OBJS): %.o: %.c
	$(GCC) $(GCC_FLAG) $< -o $@

objdump: $(OBJS)
	$(foreach OBJ, $(OBJS), $(OBJDUMP) $(OBJ_FLAG) $(OBJ) > $(basename $(OBJ))_disasm.txt;)

dump: $(OBJS)
	$(foreach OBJ, $(OBJS), $(OBJTOOL) --dump $(OBJ);)

orc: $(OBJS)
	$(foreach OBJ, $(OBJS), $(OBJTOOL) -o $(OBJ);)

clean:
	rm -rf *.o *.txt

.PHONY: clean objdump dump orc
